package com.qhy.springcloud.controller;

import com.qhy.springcloud.api.Dept;
import com.qhy.springcloud.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author qiuhongyu
 * @date 2020/9/25 17:26
 */
@RestController
public class DeptController {
    @Autowired
    private DeptService deptService;

    @PostMapping("/addDept")
    public void addDept(@RequestBody Dept dept) {
        deptService.addDept(dept);
    }

    @GetMapping("/queryDept/{id}")
    public Dept queryDept(@PathVariable("id") Long id) {
        Dept dept = deptService.queryDept(id);
        return dept;
    }

    @GetMapping("/queryDepts")
    public List<Dept> queryDepts() {
        List<Dept> deptList = deptService.queryDepts();
        return deptList;
    }
}
